package com.fen.demo;

import com.fen.dao.BeanDao;
import com.fen.dao.UserDao;
import com.fen.init.bean.three.Three1;
import com.fen.init.bean.three.Three2;
import com.fen.init.bean.three.ThreeFactory;
import com.fen.init.bean.two.Two;
import com.fen.mapper.UserMapper;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author : lrf
 * @description :
 * @tip :
 * @date : 2019/3/10
 */
public class Main {

    public static void main(String[] args) {

        ApplicationContext context =
                new ClassPathXmlApplicationContext("services.xml", "daos.xml");

        UserDao userDao = context.getBean("userDao", UserDao.class);

        System.out.println("userDao = " + userDao);

        System.out.println("-------------------------");
        BeanDao beanDao = context.getBean("beanDao", BeanDao.class);
        System.out.println("beanDao = " + beanDao);
        System.out.println("-------------------------");
        UserMapper userMapper = context.getBean("userMapper", UserMapper.class);
        System.out.println("userMapper = " + userMapper);
        System.out.println("-------------------------");


        // 实例化Bean的第二种方式，静态工厂实例化
        Two two = context.getBean("two", Two.class);
        System.out.println("two = " + two);
        System.out.println("-------------------------");

        // 实例化Bean的第三种方式，实例工厂方法实例化
        ThreeFactory threeFactory = context.getBean("threeFactory", ThreeFactory.class);
        System.out.println("threeFactory = " + threeFactory);
        Three1 three1 = context.getBean("three1", Three1.class);
        System.out.println("three1 = " + three1);
        Three2 three2 = context.getBean("three2", Three2.class);
        System.out.println("three2 = " + three2);
        System.out.println("-------------------------");
        System.out.println("-------------------------");
        System.out.println("-------------------------");


    }
}
